#ifndef SERVER_H
#define SERVER_H

#include <deque>

#include "CharacterServer.h"
#include "Tmx.h"
#include "KeyBoardAction.h"
#include "ListAction.h"
#include "ServerWorldObjects.h"

using namespace std;

class cServer {

	private :

		/*Variables de gestion de la partie*/
		int* map;
		int nb_player, waitConnect;
		bool partyStart;
		bool partyExist;

		sf::Mutex mutexListAction;

		/*Variables de gestion des connections*/
		sf::TcpListener listenerSocketPlayer;
		sf::TcpSocket socketPlayer1;
		sf::TcpSocket socketPlayer2;

		/*Variables de gestion des personnages*/
		sf::Clock chronoCh1;
		CharacterServer* character1;
		CharacterServer* character2;
		bool upPressedCh1, downPressedCh1, leftPressedCh1, rightPressedCh1;
		bool upPressedCh2, downPressedCh2, leftPressedCh2, rightPressedCh2;
		 
		deque<List_Action> liste_action;

		ServerWorldObjects* swo;

		void pushBackInActionList(List_Action current_action);
		List_Action getFirstElementFromActionList();

	public :
		/*Variables de gestion des threads*/
		sf::Thread* threadKeyBoardCharacter1;
		sf::Thread* threadKeyBoardCharacter2;
		
		/*Methodes*/
		cServer(int lenX, int lenY, int nbP);
		void launchTCPConnectionPlayer1();
		void launchTCPConnectionPlayer2();
		int launchGame();
		void animationPlayer1();
		void animationPlayer2();
		void listenKeyBoardPlayer1();
		void listenKeyBoardPlayer2();
};


#endif